// Copyright: Personal possession of Nguyen Minh Kha
// Description: This class mux many object, manage what you see on screen
// License: free source
// Date time: 07/07/2011(mm/dd/yyyy)
// Writer: Nguyen Minh Kha

#include <Windows.h>
#include <d3d9.h>
#include <d3dx9.h>
#include "log.h"
#include "resource.h"

#ifndef GAMEFRAMEWORK_VIDEO_H_
#define GAMEFRAMEWORK_VIDEO_H_

class Screen
{
  //
  // Static
  //

public:
   // Screen width, height
  static int screenWidth;
  static int screenHeight;
  static Screen *screen;
  //
  // Constructor, destructor
  //
public:
  Screen(void);
  // Create new screen object
  // hWnd: input, unchange, use as param to create directx3d device
  ~Screen(void);

  //
  // Method
  //

public:
  // Description: use after you init and create a window instance in
  // game class
  // hWnd: window handle param for creating directx3d divice
  // return: true if init sucessful, otherwise false.
  // Sample usage:
  //   hWnd = CreateWindow(....);
  //   screen.Init(hWnd);
  bool Init(HWND hWnd);
  void Release();
  static void ChangeWindowSize(int width, int height);
  bool Screen::WillPrintNextFrame();
  LPDIRECT3DDEVICE9 getDevive() {return d3ddev;}
  LPDIRECT3DSURFACE9 getBackBuffer() {return backBuffer;}
  LPDIRECT3DSURFACE9 getSurface() {return surface;}
  //
  // Data member
  //

private:
  LPDIRECT3D9 d3d;
  D3DPRESENT_PARAMETERS d3dpp;
  LPDIRECT3DDEVICE9 d3ddev;
  LPDIRECT3DSURFACE9 backBuffer;
  LPDIRECT3DSURFACE9 surface;
  HWND hWnd;
  // How many tick counted (ms) for an frame show on screen
  DWORD countPerFrame;
  DWORD prevTick;
  DISALLOW_COPY_AND_ASSIGN(Screen);
};
#endif // GAMEFRAMEWORK_VIDEO_H_
